import random
import time
#初始化文件
# with open("获奖名单.txt",'w+') as f:
#     f.read()
print(f'{"送礼程序":#^50}')
print("抽奖开始")
time.sleep(0.5)
# 定义员工名单
staff_list= ['唐僧', '猪八戒', '孙悟空', '王母娘娘']
#定义已经送过礼品的名单
send_list = []
# 定义收到礼品的名单
get_gift_list = []
# 定义礼品名单
gift_list = ['奥迪A3购买优惠券', 'apple 12 pro', '现金5W', '公司股份100股']

# 抽奖函数
def random_gift():
# 获取公司员工人数
 while True:
          send_num = random.randint(0,len(staff_list)-1)
          name = staff_list[send_num]
# 判断该送礼员工是否已经送过礼品了
          if name in send_list:
              continue
          else:
# 移除现在送礼的员工
           staff_list.remove(name)
           get_gift_staffnum = random.randint(0,len(staff_list)-1)
           staff_list.append(name)
# 判断该编号员工是否已经收过礼物了
          if staff_list[get_gift_staffnum] in get_gift_list:
              continue
          else:
              get_gift_list.append(staff_list[get_gift_staffnum])
              print(name+"的礼物送给了"+staff_list[get_gift_staffnum])
              send_list.append(name)
          time.sleep(1)
          if len(send_list) == 4:
              break




# # 随机抽奖函数
# def random_gift():
# # 获得需要抽奖总人数
#     staff_num = len(no_gift)
#     for i in range(staff_num):
#         name = no_gift[i]
#         print("%s获得了:"%(no_gift[i]),end='')
#
# # 每个礼品抽奖间隔1s
#         time.sleep(1)
# # 获得剩余礼品的数量num
#         num = len(gift_list)
# # 随机抽取礼品
#         gift_num = random.randint(0,num-1)
#         print("%s"%(gift_list[gift_num]))
#         print()
# # 获奖情况写入文件
#         with open("获奖名单.txt",'a+',encoding="utf-8") as fp:
#             fp.writelines(name+"获得了"+gift_list[gift_num]+'\n')
# # 记录以及抽完奖品的人
#         get_gift.append(no_gift[i])
# # 删除已经匹配的奖品
#         gift_list.pop(gift_num)
#         time.sleep(1)
#     print("抽奖结束！")
random_gift()
